<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:pgh="http://tecnologie-web.studenti.math.unipd.it/tecweb/~ccardin/"
    exclude-result-prefixes="pgh">


<xsl:output method='xml' version='1.0' encoding='UTF-8' indent='yes' omit-xml-declaration='yes'/>
    <!-- set the page index -->
    <xsl:variable name="pageId" select="'__PAGEID__'"/>

	<xsl:template match="/">
            <ul class="dropdown">
		<xsl:apply-templates select="pgh:pageheader/pgh:nav"/>
            </ul>
	</xsl:template> 
	
	<xsl:template match="pgh:link">
            <li>
                <xsl:call-template name="print-link"/>
            </li>
	</xsl:template>
         
        <xsl:template match="pgh:toplink">
            <li class="dir">
                <xsl:call-template name="print-link"/>
                <ul>
                    <xsl:for-each select="pgh:sublinks/pgh:sublink">
                        <li><xsl:call-template name="print-link"/></li>
                    </xsl:for-each>
                </ul>
            </li>
	</xsl:template>
	
        <xsl:template name="print-link">
                <xsl:choose>
                    <xsl:when test="pgh:anchor=$pageId">
                        <xsl:value-of select="pgh:name"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <a href="{pgh:anchor}.cgi" tabindex="{pgh:tabindex}">
			    <xsl:if test="pgh:accesskey">
                                <xsl:attribute name="accesskey">
                                    <xsl:value-of select="pgh:accesskey"/>
                                </xsl:attribute>
                            </xsl:if>
                            <xsl:value-of select="pgh:name"/>
                            <xsl:if test="pgh:accesskey">
                                <span class="dropcap"> [<xsl:value-of select="pgh:accesskey"/>]</span>
                            </xsl:if>
                        </a>
                    </xsl:otherwise>
                </xsl:choose>
        </xsl:template>
</xsl:stylesheet>
